// pages/home/my/my.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    hidden: true,
    login: true,
    rotate: false,
    rotate1: true,
    rotate2: true,
    rotate3: true,
    rotate4: true,
    src: ['https://mmbiz.qpic.cn/mmbiz_jpg/k1qgBte1czHyYxokGTibz9PkqqhMibJzthic4df4fM8ibK8BArcrv1aTiabmYQU8kKVTfd88ItFXAblYwr0jmGibIJUQ/640?wx_fmt=jpeg&tp=webp&wxfrom=5&wx_lazy=1']
  },
  dlxh: function(res) {
    var that = this;
    that.setData({
      dlxh: res.detail.value
    })
  },
  dlsf: function(res) {
    var that = this;
    that.setData({
      dlsf: res.detail.value
    })
  },
  zx: function() {
    var that = this;
    wx.removeStorage({
      key: 'dl',
      success: function(res) {
        console.log(res)
        that.setData({
          login: true
        })
      }
    })
  },
  ewm:function(e){
    wx.previewImage({
      current: e.currentTarget.dataset.img,
      urls: this.data.src
    })
  },
  dl: function(res) {
    var that = this;
    wx.request({
      url: 'https://welcome.gongxueyun.com/welcome/yingxin/login.php',
      data: {
        xh: that.data.dlxh,
        sfzh: that.data.dlsf
      },
      header: {
        'content-type': 'application/json'
      },
      success: function(res) {
        console.log(res)
        if (res.data.xm !== null) {
          that.setData({
            login: false,
            xm: res.data.xm,
            xb: res.data.xb,
            ksh: res.data.ksh,
            xh: res.data.xh,
            csrq: res.data.csrq,
            yx: res.data.yx,
            zy: res.data.zy,
            zsdz: res.data.zsdz
          })
          wx.setStorage({
            key: "dl",
            data: res.data
          })
        } else {
          wx.showToast({
            title: '请输入正确信息',
            icon: 'none',
            duration: 1000
          })
        }
      }
    })
  },

  rotate: function(res) {
    var that = this;
    that.setData({
      rotate: !that.data.rotate
    })
  },
  rotate1: function(res) {
    var that = this;
    that.setData({
      rotate1: !that.data.rotate1
    })
  },
  rotate2: function(res) {
    var that = this;
    that.setData({
      rotate2: !that.data.rotate2
    })
  },
  rotate3: function (res) {
    var that = this;
    that.setData({
      rotate3: !that.data.rotate3
    })
  },
  rotate4: function (res) {
    var that = this;
    that.setData({
      rotate4: !that.data.rotate4
    })
  },

  onLoad: function(options) {
    var that = this;
    setTimeout(function() {
      that.setData({
        hidden: false
      });
    }, 1000)

    try {
      var res = wx.getStorageSync('dl')
      if (res) {
        that.setData({
          login: false,
          xm: res.xm,
          xb: res.xb,
          ksh: res.ksh,
          xh: res.xh,
          csrq: res.csrq,
          yx: res.yx,
          zy: res.zy,
          zsdz: res.zsdz
        })
      }
    } catch (e) {
      console.log(e)
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})